#include "Rook.h"

Rook::Rook(enum FigureColor color) : Figure(color)
{
}

QString Rook::getImage() const
{
    if(color == BLACK)
        return "./images/blackrook.png";
    else
        return "./images/whiterook.png";
}

AllMoves Rook::moves() const
{
    AllMoves m;

    int x, y, position[2];

    Position::position2index(currentPosition, position);

    x = position[1];
    y = position[0];

    while(++x <= 7) {
        QVector<int> coords(2);
        coords[0] = y;
        coords[1] = x;

        m.append(coords);
    }

    x = position[1];
    y = position[0];

    while(--x >= 0) {
        QVector<int> coords(2);
        coords[0] = y;
        coords[1] = x;

        m.append(coords);
    }

    x = position[1];
    y = position[0];

    while(++y <= 7) {
        QVector<int> coords(2);
        coords[0] = y;
        coords[1] = x;

        m.append(coords);
    }

    x = position[1];
    y = position[0];

    while(--y >= 0) {
        QVector<int> coords(2);
        coords[0] = y;
        coords[1] = x;

        m.append(coords);
    }

    return m;
}
